# Maintainer:  Christian Rebischke <chris.rebischke@archlinux.org>
# Maintainer:  Andreas 'Segaja' Schleifer <segaja at archlinux dot org>
# Contributor: Stefan Tatschner <rumpelsepp@sevenbyte.org>
# Contributor: Nick Østergaard <oe.nick at gmail dot com>
# Contributor: Nicolas Bigaouette <nbigaouette@chemcomp.com>

pkgname='asciidoctor'
pkgver=2.0.20
pkgrel=1
pkgdesc='An implementation of AsciiDoc in Ruby'
arch=('any')
url='https://asciidoctor.org'
license=('MIT')
makedepends=('ruby-rdoc')
depends=('ruby')
options=('!emptydirs')
source=("https://rubygems.org/downloads/${pkgname}-${pkgver}.gem")
noextract=("$pkgname-$pkgver.gem")
sha512sums=('de0179ae27443ddd04153ae0c941939523372203c561e5bb8a900af80b1056d6a3d8b554015d37836efb9bdf870d4d115272607f4d548956fc240c028abfbcf2')

package() {
    local _gemdir="$(ruby -e 'puts Gem.default_dir')"

    gem install --ignore-dependencies --no-user-install --verbose \
        -i "$pkgdir/$_gemdir" -n "$pkgdir/usr/bin" \
        "$pkgname-$pkgver.gem"

    install -Dm644 "$pkgdir/$_gemdir/gems/$pkgname-$pkgver/LICENSE" \
        "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
    install -Dm644 "$pkgdir/$_gemdir/gems/$pkgname-$pkgver/man/asciidoctor.1" \
        "$pkgdir/usr/share/man/man1/asciidoctor.1"

    rm "$pkgdir/$_gemdir/cache/$pkgname-$pkgver.gem"
    rm -rf "$pkgdir/$_gemdir/gems/$pkgname-$pkgver/man"
}
